import { util } from "utils";
import DingInfo from "../config";
// 获取 推送的内容
function getGroupPushContent(sizuList: any[], sep: string = "\r\n"): [string, string[]] {
    const currentStatus = (item: { [k: string]: any }, key: string) => {
        let v = item[key];
        if (util.nilValue(v)) {
            return `未知`;
        }
        // return v ? "✅💯" : "❌❗️️🚫💯💢";
        return v ? "💯" : "❗️️";
    };

    //     name, input: input || "", // 可能今天没有填写...

    // 要@ 的人
    let atMobiles = [] as string[];
    let notifyUsersNames = DingInfo.notifyUsers.map((e) => e.name);

    // 处理 要 @ 的 人
    let msgArr = sizuList.map((item) => {
        let user = `${item.name || ""}`;
        // 判断是不是要 @ 的人
        let isNotifyIndex = notifyUsersNames.findIndex((e) => {
            return e.trim() === user.trim();
        });
        if (isNotifyIndex >= 0) {
            // 判断写没写
            if (util.emptyValue(item?.input)) {
                // 没写呢
                atMobiles.push(DingInfo.notifyUsers[isNotifyIndex].phone);
            }
        }
        return `${user} ${currentStatus(item, "input")}`;
    });
    if (msgArr.length > 0) {
        msgArr.push(`截止到 ${util.baseDateDes(new Date())}`);
    }

    return [msgArr.join(sep), atMobiles];
}

export { getGroupPushContent };
